home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / dial / autodial.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-09-12  |  4.1 KB  |  113 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Auto-Dial"
  5.    ClientHeight    =   1830
  6.    ClientLeft      =   3765
  7.    ClientTop       =   3720
  8.    ClientWidth     =   3510
  9.    Height          =   2235
  10.    Left            =   3705
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   1830
  15.    ScaleWidth      =   3510
  16.    ShowInTaskbar   =   0   'False
  17.    Top             =   3375
  18.    Width           =   3630
  19.    Begin VB.CommandButton cmdExit 
  20.       Caption         =   "E&xit"
  21.       Height          =   375
  22.       Left            =   1920
  23.       TabIndex        =   3
  24.       Top             =   1200
  25.       Width           =   1215
  26.    End
  27.    Begin VB.CommandButton cmdDial 
  28.       Caption         =   "&Dial..."
  29.       Height          =   375
  30.       Left            =   360
  31.       TabIndex        =   2
  32.       Top             =   1200
  33.       Width           =   1215
  34.    End
  35.    Begin VB.TextBox txtNumber 
  36.       Height          =   285
  37.       Left            =   120
  38.       TabIndex        =   0
  39.       Top             =   600
  40.       Width           =   3255
  41.    End
  42.    Begin VB.Label Label1 
  43.       Caption         =   "&Phone Number:"
  44.       Height          =   255
  45.       Left            =   120
  46.       TabIndex        =   1
  47.       Top             =   360
  48.       Width           =   1935
  49.    End
  50. Attribute VB_Name = "Form1"
  51. Attribute VB_Creatable = False
  52. Attribute VB_Exposed = False
  53. 'AutoDial - Telephone dialer demo program
  54. 'Copyright (c) 1996 SoftCircuits
  55. 'Redistributed by Permission.
  56. 'This Visual Basic 4.0 example program demonstrates how an application
  57. 'can dial a telephone number under Windows 95 using Assisted Telephony
  58. 'which is a subset of TAPI. This code is simple because it relies on a
  59. 'call manager applet to perform the actual dialing.
  60. 'This program may be distributed on the condition that it is
  61. 'distributed in full and unchanged, and that no fee is charged for
  62. 'such distribution with the exception of reasonable shipping and media
  63. 'charged. In addition, the code in this program may be incorporated
  64. 'into your own programs and the resulting programs may be distributed
  65. 'without payment of royalties.
  66. 'This example program was provided courtesy of:
  67. ' SoftCircuits Programming
  68. ' P.O. Box 16262
  69. ' Irvine, CA 92623
  70. ' http://www.softcircuits.com
  71. Option Explicit
  72. Private Declare Function tapiRequestMakeCall& Lib "TAPI32.DLL" (ByVal DestAddress$, ByVal AppName$, ByVal CalledParty$, ByVal Comment$)
  73. Private Const TAPIERR_NOREQUESTRECIPIENT = -2&
  74. Private Const TAPIERR_REQUESTQUEUEFULL = -3&
  75. Private Const TAPIERR_INVALDESTADDRESS = -4&
  76. Private Sub cmdDial_Click()
  77.     Dim buff As String
  78.     Dim nResult As Long
  79.     'Invoke tapiRequestMakeCall. If tapiRequestMakeCall returns 0, the
  80.     'request has been accepted. It is up to the call manager application
  81.     'to do any further work. The second-to-last argument should be
  82.     'changed to be the name of the person you are dialing.
  83.     nResult = tapiRequestMakeCall&(Trim$(txtNumber), CStr(Caption), "Test Dial", "")
  84.     'Display message if error
  85.     If nResult <> 0 Then
  86.         buff = "Error dialing number : "
  87.         Select Case nResult
  88.             Case TAPIERR_NOREQUESTRECIPIENT
  89.                 buff = buff & "No Windows Telephony dialing application is running and none could be started."
  90.             Case TAPIERR_REQUESTQUEUEFULL
  91.                 buff = buff & "The queue of pending Windows Telephony dialing requests is full."
  92.             Case TAPIERR_INVALDESTADDRESS
  93.                 buff = buff & "The phone number is not valid."
  94.             Case Else
  95.                 buff = buff & "Unknown error."
  96.         End Select
  97.         MsgBox buff
  98.     End If
  99. End Sub
  100. Private Sub cmdExit_Click()
  101.     Unload Me
  102. End Sub
  103. Private Sub Form_Load()
  104.     Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
  105.     EnableDial
  106. End Sub
  107. Private Sub txtNumber_Change()
  108.     EnableDial
  109. End Sub
  110. Private Sub EnableDial()
  111.     cmdDial.Enabled = Len(Trim$(txtNumber)) > 0
  112. End Sub
  113.